package com.csthink.utils;

import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Random;

/**
 * @author <a href="mailto:csthink@icloud.com">Mars</a>
 * @since 2024-04-15 08:58
 */
public class MockUtil {

    public static void main(String[] args) throws Exception {
        createBigFile();
    }

    public static void createBigFile() throws Exception {
        String[] words = new String[]{"jack", "rose", "lucy"};
        Random random = new Random();

        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
                Files.newOutputStream(Paths.get("data/big.txt")), StandardCharsets.UTF_8
        ));

        for (int i = 0; i < 1000000; i++) {
            for (int j = 0; j < 30; j++) {
                writer.write(words[random.nextInt(words.length)]);
                writer.write(",");
            }
            writer.newLine();
        }
        writer.flush();
        writer.close();
    }
}
